{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Collecting pyecharts\n",
      "  Downloading pyecharts-1.9.1-py3-none-any.whl (135 kB)\n",
      "Collecting prettytable\n",
      "  Downloading prettytable-3.3.0-py3-none-any.whl (26 kB)\n",
      "Collecting simplejson\n",
      "  Downloading simplejson-3.17.6-cp38-cp38-win_amd64.whl (75 kB)\n",
      "Requirement already satisfied: jinja2 in c:\\users\\dell\\anaconda3\\lib\\site-packages (from pyecharts) (2.11.2)\n",
      "Requirement already satisfied: wcwidth in c:\\users\\dell\\anaconda3\\lib\\site-packages (from prettytable->pyecharts) (0.2.5)\n",
      "Requirement already satisfied: MarkupSafe>=0.23 in c:\\users\\dell\\anaconda3\\lib\\site-packages (from jinja2->pyecharts) (1.1.1)\n",
      "Installing collected packages: prettytable, simplejson, pyecharts\n",
      "Successfully installed prettytable-3.3.0 pyecharts-1.9.1 simplejson-3.17.6\n"
     ]
    }
   ],
   "source": [
    "#   饼图作业操作\n",
    "!pip install pyecharts"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"f216a9ccfef24d639814c6b281bb79f8\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_f216a9ccfef24d639814c6b281bb79f8 = echarts.init(\n",
       "                    document.getElementById('f216a9ccfef24d639814c6b281bb79f8'), 'white', {renderer: 'canvas'});\n",
       "                var option_f216a9ccfef24d639814c6b281bb79f8 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"pie\",\n",
       "            \"name\": \"\\u5e7f\\u4e1c\",\n",
       "            \"clockwise\": true,\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"2016y\",\n",
       "                    \"value\": 80854.91\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"2015y\",\n",
       "                    \"value\": 72812.55\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"2014y\",\n",
       "                    \"value\": 67809.85\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"2013y\",\n",
       "                    \"value\": 62474.79\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"2012y\",\n",
       "                    \"value\": 57067.92\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"2011y\",\n",
       "                    \"value\": 53210.28\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"2010y\",\n",
       "                    \"value\": 46013.06\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"2009y\",\n",
       "                    \"value\": 39482.56\n",
       "                }\n",
       "            ],\n",
       "            \"radius\": [\n",
       "                0,\n",
       "                140\n",
       "            ],\n",
       "            \"center\": [\n",
       "                \"25%\",\n",
       "                \"50%\"\n",
       "            ],\n",
       "            \"roseType\": \"area\",\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            }\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"pie\",\n",
       "            \"name\": \"\\u6c5f\\u82cf\",\n",
       "            \"clockwise\": true,\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"2016y\",\n",
       "                    \"value\": 77388.28\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"2015y\",\n",
       "                    \"value\": 70116.38\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"2014y\",\n",
       "                    \"value\": 65088.32\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"2013y\",\n",
       "                    \"value\": 59753.37\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"2012y\",\n",
       "                    \"value\": 54058.22\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"2011y\",\n",
       "                    \"value\": 49110.27\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"2010y\",\n",
       "                    \"value\": 41425.48\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"2009y\",\n",
       "                    \"value\": 34457.3\n",
       "                }\n",
       "            ],\n",
       "            \"radius\": [\n",
       "                0,\n",
       "                140\n",
       "            ],\n",
       "            \"center\": [\n",
       "                \"75%\",\n",
       "                \"50%\"\n",
       "            ],\n",
       "            \"roseType\": \"area\",\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"2016y\",\n",
       "                \"2015y\",\n",
       "                \"2014y\",\n",
       "                \"2013y\",\n",
       "                \"2012y\",\n",
       "                \"2011y\",\n",
       "                \"2010y\",\n",
       "                \"2009y\"\n",
       "            ],\n",
       "            \"selected\": {}\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    }\n",
       "};\n",
       "                chart_f216a9ccfef24d639814c6b281bb79f8.setOption(option_f216a9ccfef24d639814c6b281bb79f8);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x21009ddee80>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\n",
    "from pyecharts.charts import Pie #从pyecharts中导入line类\n",
    "from pyecharts import options as opts#使用 options 配置项\n",
    "import pandas as pd\n",
    "df = pd.read_csv(r\"gdp.csv\")\n",
    "\n",
    "years = df.iloc[0,1:9].index.tolist()\n",
    "gd = df.iloc[18, 1:9].values.tolist()\n",
    "js = df.iloc[9, 1:9].values.tolist()\n",
    "\n",
    "pie = (\n",
    "    Pie()\n",
    "\n",
    "    .add(\"广东\", [list(z) for z in zip(years, gd)],\n",
    "    center=[\"25%\", \"50%\"],\n",
    "    radius=[0, 140],\n",
    "    rosetype=\"area\")\n",
    "    \n",
    "    .add(\"江苏\", [list(z) for z in zip(years, js)],\n",
    "    center=[\"75%\", \"50%\"],\n",
    "    radius=[0, 140],\n",
    "    rosetype=\"area\")\n",
    "    )\n",
    "pie.render_notebook()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"ab96d9c0ef9343ba895c3a9eda7be788\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_ab96d9c0ef9343ba895c3a9eda7be788 = echarts.init(\n",
       "                    document.getElementById('ab96d9c0ef9343ba895c3a9eda7be788'), 'white', {renderer: 'canvas'});\n",
       "                var option_ab96d9c0ef9343ba895c3a9eda7be788 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"pie\",\n",
       "            \"clockwise\": true,\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u5e7f\\u4e1c\\u7701\",\n",
       "                    \"value\": 67809.85\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6c5f\\u82cf\\u7701\",\n",
       "                    \"value\": 65088.32\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5c71\\u4e1c\\u7701\",\n",
       "                    \"value\": 59426.59\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6d59\\u6c5f\\u7701\",\n",
       "                    \"value\": 40173.03\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6cb3\\u5357\\u7701\",\n",
       "                    \"value\": 34938.24\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6cb3\\u5317\\u7701\",\n",
       "                    \"value\": 29421.15\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8fbd\\u5b81\\u7701\",\n",
       "                    \"value\": 28626.58\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u56db\\u5ddd\\u7701\",\n",
       "                    \"value\": 28536.66\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6e56\\u5317\\u7701\",\n",
       "                    \"value\": 27379.22\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6e56\\u5357\\u7701\",\n",
       "                    \"value\": 27037.32\n",
       "                }\n",
       "            ],\n",
       "            \"radius\": [\n",
       "                40,\n",
       "                80\n",
       "            ],\n",
       "            \"center\": [\n",
       "                \"50%\",\n",
       "                \"50%\"\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8,\n",
       "                \"formatter\": \"{b}: {c}\"\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u5e7f\\u4e1c\\u7701\",\n",
       "                \"\\u6c5f\\u82cf\\u7701\",\n",
       "                \"\\u5c71\\u4e1c\\u7701\",\n",
       "                \"\\u6d59\\u6c5f\\u7701\",\n",
       "                \"\\u6cb3\\u5357\\u7701\",\n",
       "                \"\\u6cb3\\u5317\\u7701\",\n",
       "                \"\\u8fbd\\u5b81\\u7701\",\n",
       "                \"\\u56db\\u5ddd\\u7701\",\n",
       "                \"\\u6e56\\u5317\\u7701\",\n",
       "                \"\\u6e56\\u5357\\u7701\"\n",
       "            ],\n",
       "            \"selected\": {}\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    }\n",
       "};\n",
       "                chart_ab96d9c0ef9343ba895c3a9eda7be788.setOption(option_ab96d9c0ef9343ba895c3a9eda7be788);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x210099ba1f0>"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "from pyecharts.charts import Page, Pie\n",
    "from pyecharts import options as opts\n",
    "df = pd.read_csv(r\"gdp.csv\")\n",
    "\n",
    "df.sort_values('2014y',ascending=False, inplace = True)\n",
    "\n",
    "\n",
    "def pie_base() -> Pie:\n",
    "    c = (\n",
    "        Pie()\n",
    "        .add(\"\", list(zip( df['province'].head(10) ,   df['2014y'].head(10))), \n",
    "        radius=[40, 80],)\n",
    "        .set_series_opts(label_opts=opts.LabelOpts(formatter=\"{b}: {c}\"))\n",
    "    )\n",
    "    return c\n",
    "pie_base().render_notebook()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# ========================================================================================================================================"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 柱形图作业操作"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"284743c268db4ea4961e2290c4e53ceb\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_284743c268db4ea4961e2290c4e53ceb = echarts.init(\n",
       "                    document.getElementById('284743c268db4ea4961e2290c4e53ceb'), 'white', {renderer: 'canvas'});\n",
       "                var option_284743c268db4ea4961e2290c4e53ceb = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"2014y\",\n",
       "            \"legendHoverLink\": true,\n",
       "            \"data\": [\n",
       "                920.83,\n",
       "                2303.32,\n",
       "                2752.1,\n",
       "                3500.72,\n",
       "                6836.82,\n",
       "                9266.39,\n",
       "                9273.46,\n",
       "                12761.49,\n",
       "                12814.59,\n",
       "                13803.14,\n",
       "                14262.6,\n",
       "                15039.38,\n",
       "                15672.89,\n",
       "                15714.63,\n",
       "                15726.93,\n",
       "                17689.94,\n",
       "                17770.19,\n",
       "                20848.75,\n",
       "                21330.83,\n",
       "                23567.7,\n",
       "                24055.76,\n",
       "                27037.32,\n",
       "                27379.22,\n",
       "                28536.66,\n",
       "                28626.58,\n",
       "                29421.15,\n",
       "                34938.24,\n",
       "                40173.03,\n",
       "                59426.59,\n",
       "                65088.32,\n",
       "                67809.85\n",
       "            ],\n",
       "            \"showBackground\": false,\n",
       "            \"barMinHeight\": 0,\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"barGap\": \"30%\",\n",
       "            \"large\": false,\n",
       "            \"largeThreshold\": 400,\n",
       "            \"seriesLayoutBy\": \"column\",\n",
       "            \"datasetIndex\": 0,\n",
       "            \"clip\": true,\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"2014y\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"2014y\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"\\u897f\\u85cf\",\n",
       "                \"\\u9752\\u6d77\\u7701\",\n",
       "                \"\\u5b81\\u590f\",\n",
       "                \"\\u6d77\\u5357\\u7701\",\n",
       "                \"\\u7518\\u8083\\u7701\",\n",
       "                \"\\u8d35\\u5dde\\u7701\",\n",
       "                \"\\u65b0\\u7586\",\n",
       "                \"\\u5c71\\u897f\\u7701\",\n",
       "                \"\\u4e91\\u5357\\u7701\",\n",
       "                \"\\u5409\\u6797\\u7701\",\n",
       "                \"\\u91cd\\u5e86\\u5e02\",\n",
       "                \"\\u9ed1\\u9f99\\u6c5f\\u7701\",\n",
       "                \"\\u5e7f\\u897f\",\n",
       "                \"\\u6c5f\\u897f\\u7701\",\n",
       "                \"\\u5929\\u6d25\\u5e02\",\n",
       "                \"\\u9655\\u897f\\u7701\",\n",
       "                \"\\u5185\\u8499\\u53e4\",\n",
       "                \"\\u5b89\\u5fbd\\u7701\",\n",
       "                \"\\u5317\\u4eac\\u5e02\",\n",
       "                \"\\u4e0a\\u6d77\\u5e02\",\n",
       "                \"\\u798f\\u5efa\\u7701\",\n",
       "                \"\\u6e56\\u5357\\u7701\",\n",
       "                \"\\u6e56\\u5317\\u7701\",\n",
       "                \"\\u56db\\u5ddd\\u7701\",\n",
       "                \"\\u8fbd\\u5b81\\u7701\",\n",
       "                \"\\u6cb3\\u5317\\u7701\",\n",
       "                \"\\u6cb3\\u5357\\u7701\",\n",
       "                \"\\u6d59\\u6c5f\\u7701\",\n",
       "                \"\\u5c71\\u4e1c\\u7701\",\n",
       "                \"\\u6c5f\\u82cf\\u7701\",\n",
       "                \"\\u5e7f\\u4e1c\\u7701\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ],\n",
       "    \"dataZoom\": {\n",
       "        \"show\": true,\n",
       "        \"type\": \"slider\",\n",
       "        \"realtime\": true,\n",
       "        \"start\": 100,\n",
       "        \"end\": 50,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"zoomLock\": false,\n",
       "        \"filterMode\": \"filter\"\n",
       "    }\n",
       "};\n",
       "                chart_284743c268db4ea4961e2290c4e53ceb.setOption(option_284743c268db4ea4961e2290c4e53ceb);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x210099b50d0>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#   1.1\n",
    "from pyecharts.charts import Bar#从pyecharts中导入line类\n",
    "from pyecharts import options as opts#使用 options 配置项\n",
    "from pyecharts.globals import CurrentConfig\n",
    "import pandas as pd\n",
    "\n",
    "year = '2014y'\n",
    "\n",
    "df = pd.read_csv(r\"gdp.csv\")\n",
    "df_of_year = df[['province', year]].sort_values(by=year, ascending=True)\n",
    "\n",
    "provinces = df_of_year['province'].values.tolist()\n",
    "values = df_of_year[year].values.tolist()\n",
    "\n",
    "bar = (\n",
    "       Bar()\n",
    "       .add_xaxis(eval(repr(provinces)))\n",
    "       .add_yaxis(year, eval(repr(values)))\n",
    "       .reversal_axis()\n",
    "       .set_global_opts( datazoom_opts=opts.DataZoomOpts(orient=\"vertical\",range_start =100, range_end=50))\n",
    "       )\n",
    "\n",
    "bar.render_notebook()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"0caa0e60b991464ebf5ddbb0fcdeb520\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_0caa0e60b991464ebf5ddbb0fcdeb520 = echarts.init(\n",
       "                    document.getElementById('0caa0e60b991464ebf5ddbb0fcdeb520'), 'white', {renderer: 'canvas'});\n",
       "                var option_0caa0e60b991464ebf5ddbb0fcdeb520 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u5317\\u4eac\\u5e02\",\n",
       "            \"legendHoverLink\": true,\n",
       "            \"data\": [\n",
       "                19800.81,\n",
       "                17879.4,\n",
       "                16251.93,\n",
       "                14113.58\n",
       "            ],\n",
       "            \"showBackground\": false,\n",
       "            \"barMinHeight\": 0,\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"barGap\": \"30%\",\n",
       "            \"large\": false,\n",
       "            \"largeThreshold\": 400,\n",
       "            \"seriesLayoutBy\": \"column\",\n",
       "            \"datasetIndex\": 0,\n",
       "            \"clip\": true,\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"label\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"inside\",\n",
       "                    \"color\": \"#fff\",\n",
       "                    \"margin\": 8\n",
       "                },\n",
       "                \"data\": [\n",
       "                    {\n",
       "                        \"name\": \"\\u6700\\u5927\\u503c\",\n",
       "                        \"type\": \"max\"\n",
       "                    },\n",
       "                    {\n",
       "                        \"name\": \"\\u6700\\u5c0f\\u503c\",\n",
       "                        \"type\": \"min\"\n",
       "                    }\n",
       "                ]\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u4e0a\\u6d77\\u5e02\",\n",
       "            \"legendHoverLink\": true,\n",
       "            \"data\": [\n",
       "                21818.15,\n",
       "                20181.72,\n",
       "                19195.69,\n",
       "                17165.98\n",
       "            ],\n",
       "            \"showBackground\": false,\n",
       "            \"barMinHeight\": 0,\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"barGap\": \"30%\",\n",
       "            \"large\": false,\n",
       "            \"largeThreshold\": 400,\n",
       "            \"seriesLayoutBy\": \"column\",\n",
       "            \"datasetIndex\": 0,\n",
       "            \"clip\": true,\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"label\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"inside\",\n",
       "                    \"color\": \"#fff\",\n",
       "                    \"margin\": 8\n",
       "                },\n",
       "                \"data\": [\n",
       "                    {\n",
       "                        \"name\": \"\\u6700\\u5927\\u503c\",\n",
       "                        \"type\": \"max\"\n",
       "                    },\n",
       "                    {\n",
       "                        \"name\": \"\\u6700\\u5c0f\\u503c\",\n",
       "                        \"type\": \"min\"\n",
       "                    }\n",
       "                ]\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u6c5f\\u82cf\\u7701\",\n",
       "            \"legendHoverLink\": true,\n",
       "            \"data\": [\n",
       "                59753.37,\n",
       "                54058.22,\n",
       "                49110.27,\n",
       "                41425.48\n",
       "            ],\n",
       "            \"showBackground\": false,\n",
       "            \"barMinHeight\": 0,\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"barGap\": \"30%\",\n",
       "            \"large\": false,\n",
       "            \"largeThreshold\": 400,\n",
       "            \"seriesLayoutBy\": \"column\",\n",
       "            \"datasetIndex\": 0,\n",
       "            \"clip\": true,\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"label\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"inside\",\n",
       "                    \"color\": \"#fff\",\n",
       "                    \"margin\": 8\n",
       "                },\n",
       "                \"data\": [\n",
       "                    {\n",
       "                        \"name\": \"\\u6700\\u5927\\u503c\",\n",
       "                        \"type\": \"max\"\n",
       "                    },\n",
       "                    {\n",
       "                        \"name\": \"\\u6700\\u5c0f\\u503c\",\n",
       "                        \"type\": \"min\"\n",
       "                    }\n",
       "                ]\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u5e7f\\u4e1c\\u7701\",\n",
       "            \"legendHoverLink\": true,\n",
       "            \"data\": [\n",
       "                62474.79,\n",
       "                57067.92,\n",
       "                53210.28,\n",
       "                46013.06\n",
       "            ],\n",
       "            \"showBackground\": false,\n",
       "            \"barMinHeight\": 0,\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"barGap\": \"30%\",\n",
       "            \"large\": false,\n",
       "            \"largeThreshold\": 400,\n",
       "            \"seriesLayoutBy\": \"column\",\n",
       "            \"datasetIndex\": 0,\n",
       "            \"clip\": true,\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"label\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"inside\",\n",
       "                    \"color\": \"#fff\",\n",
       "                    \"margin\": 8\n",
       "                },\n",
       "                \"data\": [\n",
       "                    {\n",
       "                        \"name\": \"\\u6700\\u5927\\u503c\",\n",
       "                        \"type\": \"max\"\n",
       "                    },\n",
       "                    {\n",
       "                        \"name\": \"\\u6700\\u5c0f\\u503c\",\n",
       "                        \"type\": \"min\"\n",
       "                    }\n",
       "                ]\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u5317\\u4eac\\u5e02\",\n",
       "                \"\\u4e0a\\u6d77\\u5e02\",\n",
       "                \"\\u6c5f\\u82cf\\u7701\",\n",
       "                \"\\u5e7f\\u4e1c\\u7701\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u5317\\u4eac\\u5e02\": true,\n",
       "                \"\\u4e0a\\u6d77\\u5e02\": true,\n",
       "                \"\\u6c5f\\u82cf\\u7701\": true,\n",
       "                \"\\u5e7f\\u4e1c\\u7701\": true\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"2013y\",\n",
       "                \"2012y\",\n",
       "                \"2011y\",\n",
       "                \"2010y\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_0caa0e60b991464ebf5ddbb0fcdeb520.setOption(option_0caa0e60b991464ebf5ddbb0fcdeb520);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x210099aaa00>"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#    1.2\n",
    "\n",
    "from pyecharts.charts import Bar #从pyecharts中导入line类\n",
    "from pyecharts import options as opts#使用 options 配置项\n",
    "from pyecharts.globals import CurrentConfig\n",
    "import pandas as pd\n",
    "\n",
    "\n",
    "df = pd.read_csv(r\"gdp.csv\")\n",
    "\n",
    "df = df.iloc[[0,8,9,18], [0,4,5,6,7]].set_index(\"province\")\n",
    "\n",
    "\n",
    "def show_bar(df):\n",
    "    bar = (Bar()\n",
    "        .add_xaxis( df.index.tolist())\n",
    "    )   \n",
    "    for col in df.columns:\n",
    "        bar.add_yaxis(col, eval(repr(df[col].values.tolist())))\n",
    "    bar.set_series_opts(\n",
    "                markpoint_opts=opts.MarkPointOpts(\n",
    "                data=[\n",
    "                    opts.MarkPointItem(type_=\"max\", name=\"最大值\"),\n",
    "                    opts.MarkPointItem(type_=\"min\", name=\"最小值\"),\n",
    "                    ]   )  \n",
    "            \n",
    "        ) \n",
    "    return bar\n",
    "        \n",
    "# show_bar(df).render_notebook()     #  不同省对比各年\n",
    "show_bar(df.T).render_notebook()   # 不同年对比各省\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"a487126406b44055a24e99b073f53867\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_a487126406b44055a24e99b073f53867 = echarts.init(\n",
       "                    document.getElementById('a487126406b44055a24e99b073f53867'), 'white', {renderer: 'canvas'});\n",
       "                var option_a487126406b44055a24e99b073f53867 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u7b2c\\u4e09\\u4ea7\\u4e1a\",\n",
       "            \"legendHoverLink\": true,\n",
       "            \"data\": [\n",
       "                21.84858162690212,\n",
       "                22.438369948012745,\n",
       "                24.778024417314096,\n",
       "                28.671251109139305,\n",
       "                29.13868613138686,\n",
       "                29.637615059291818,\n",
       "                30.512530745197104,\n",
       "                32.06214689265537,\n",
       "                31.540604242554103,\n",
       "                33.68532206969377,\n",
       "                34.754670727630646\n",
       "            ],\n",
       "            \"showBackground\": false,\n",
       "            \"stack\": \"stack1\",\n",
       "            \"barMinHeight\": 0,\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"barGap\": \"30%\",\n",
       "            \"large\": false,\n",
       "            \"largeThreshold\": 400,\n",
       "            \"seriesLayoutBy\": \"column\",\n",
       "            \"datasetIndex\": 0,\n",
       "            \"clip\": true,\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": false,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u7b2c\\u4e8c\\u4ea7\\u4e1a\",\n",
       "            \"legendHoverLink\": true,\n",
       "            \"data\": [\n",
       "                44.767987976704866,\n",
       "                44.37363743082341,\n",
       "                43.09100998890122,\n",
       "                42.890417036379766,\n",
       "                43.72749391727494,\n",
       "                43.55253337756032,\n",
       "                43.78780828292229,\n",
       "                42.8319209039548,\n",
       "                41.33811870580673,\n",
       "                41.788714935035124,\n",
       "                43.45726702076292\n",
       "            ],\n",
       "            \"showBackground\": false,\n",
       "            \"stack\": \"stack1\",\n",
       "            \"barMinHeight\": 0,\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"barGap\": \"30%\",\n",
       "            \"large\": false,\n",
       "            \"largeThreshold\": 400,\n",
       "            \"seriesLayoutBy\": \"column\",\n",
       "            \"datasetIndex\": 0,\n",
       "            \"clip\": true,\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": false,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u7b2c\\u4e00\\u4ea7\\u4e1a\",\n",
       "            \"legendHoverLink\": true,\n",
       "            \"data\": [\n",
       "                33.38343039639301,\n",
       "                33.17122253899044,\n",
       "                32.13096559378468,\n",
       "                28.438331854480925,\n",
       "                27.14355231143552,\n",
       "                26.80985156314786,\n",
       "                25.693013361696472,\n",
       "                25.10593220338983,\n",
       "                27.115920291407758,\n",
       "                24.525962995271108,\n",
       "                21.791776547932994\n",
       "            ],\n",
       "            \"showBackground\": false,\n",
       "            \"stack\": \"stack1\",\n",
       "            \"barMinHeight\": 0,\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"barGap\": \"30%\",\n",
       "            \"large\": false,\n",
       "            \"largeThreshold\": 400,\n",
       "            \"seriesLayoutBy\": \"column\",\n",
       "            \"datasetIndex\": 0,\n",
       "            \"clip\": true,\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": false,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u7b2c\\u4e09\\u4ea7\\u4e1a\",\n",
       "                \"\\u7b2c\\u4e8c\\u4ea7\\u4e1a\",\n",
       "                \"\\u7b2c\\u4e00\\u4ea7\\u4e1a\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u7b2c\\u4e09\\u4ea7\\u4e1a\": true,\n",
       "                \"\\u7b2c\\u4e8c\\u4ea7\\u4e1a\": true,\n",
       "                \"\\u7b2c\\u4e00\\u4ea7\\u4e1a\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"1982\",\n",
       "                \"1983\",\n",
       "                \"1984\",\n",
       "                \"1985\",\n",
       "                \"1986\",\n",
       "                \"1987\",\n",
       "                \"1988\",\n",
       "                \"1989\",\n",
       "                \"1990\",\n",
       "                \"1991\",\n",
       "                \"1992\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u5386\\u5e74\\u4e09\\u5927\\u4ea7\\u4e1agdp\\u5bf9\\u6bd4\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_a487126406b44055a24e99b073f53867.setOption(option_a487126406b44055a24e99b073f53867);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x210099aaa60>"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#     2.1\n",
    "\n",
    "from pyecharts.charts import Bar\n",
    "from pyecharts import options as opts\n",
    "\n",
    "\n",
    "with open(r\"gdp.txt\") as f:\n",
    "    info = [line.split('\\t',5) for line in f]\n",
    "    info = [(x[0], *list(map(int, x[1:-1]))) for x in info]\n",
    "    attr = [x[0] for x in info]\n",
    "\n",
    "\n",
    "bar = (\n",
    "    Bar()\n",
    "    .add_xaxis(attr)\n",
    "    .add_yaxis(\"第三产业\", [x[4]/x[1] * 100 for x in info],stack=\"stack1\")\n",
    "    .add_yaxis(\"第二产业\", [x[3]/x[1] * 100 for x in info],stack=\"stack1\")\n",
    "    .add_yaxis(\"第一产业\", [x[2]/x[1] * 100 for x in info],stack=\"stack1\")\n",
    "    .set_global_opts(title_opts=opts.TitleOpts(title=\"历年三大产业gdp对比\"))\n",
    "    .set_series_opts(label_opts=opts.LabelOpts(False))\n",
    ")\n",
    "bar.render_notebook()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
